package com.shop.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 罗俊华
 * @date 2022/3/15 - 2:27 下午
 */
@Slf4j
@Controller
public class PageController {


    @PreAuthorize("hasAnyRole('admin')")
    @GetMapping({"/","/home"})
    public ModelAndView root(Authentication authentication){
        ModelAndView modelAndView = new ModelAndView("shopHome");

        modelAndView.addObject("userName",authentication.getPrincipal());

        return modelAndView;
    }
}
